package com.wontube.core.plugin;

import java.util.Comparator;

import com.wontube.core.plugin.IPlugin;


/**
 * @author yuechao
 * 
 *         比较插件优先级
 */
public final class PluginComparator implements Comparator<IPlugin> {
	/**
	 * 比较优先级
	 * 
	 * @param o1
	 * @param o2
	 * @return
	 */
	@Override
	public int compare(IPlugin o1, IPlugin o2) {
		float x = o1.getPriority() - o2.getPriority();
		if (x > 0) {
			return 1;

		} else if (x == 0) {
			return 0;

		} else {
			return -1;
		}
	}

	@Override
	public boolean equals(Object obj) {
		return (obj != null) && (obj instanceof PluginComparator);
	}
}
